//终极结论: HTTP请求最终会交给DispatcherServlet中的doDispatch(request, response)处理
public abstract class GenericServlet implements Servlet{
    service();
}
public abstract class HttpServlet extends GenericServlet{
     service(){
     }
}
public abstract class HttpServletBean extends HttpServlet{

}
public abstract class FrameworkServlet extends HttpServletBean{
    service(){
      processRequest(request, response);
    }
    processRequest(request,response){
        doService(request, response);
    }
}
public class DispatcherServlet extends FrameworkServlet{
    doService(request, response){
       doDispatch(request, response);
    }
}

//核心方法
protected void doDispatch(HttpServletRequest request, HttpServletResponse response) throws Exception {
		HttpServletRequest processedRequest = request;
		HandlerExecutionChain mappedHandler = null;
		boolean multipartRequestParsed = false;

		WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request);

		try {
			ModelAndView mv = null;
			Exception dispatchException = null;

			try {
				processedRequest = checkMultipart(request);
				multipartRequestParsed = (processedRequest != request);

				// Determine handler for the current request.
				//1.根据配置的HandlerMapper查找Handler
				//例如: BeanNameUrlHandlerMapper根据/hello.do找到对应Handler=>HelloController
				//最终返回的HandlerExecutionChain(封装了拦截器及找到Handler对象)
				mappedHandler = getHandler(processedRequest);
				if (mappedHandler == null) {
					noHandlerFound(processedRequest, response);
					return;
				}

				// Determine handler adapter for the current request.
				// 2.根据找到Handler匹配对应的HandlerAdapter
				//例如:配置的SimpleControllerHandlerAdapter,底层会调用HandlerAdapter的supports()方法去判断
				// Handler是否实现了Controller接口
				HandlerAdapter ha = getHandlerAdapter(mappedHandler.getHandler());

				// Process last-modified header, if supported by the handler.
				String method = request.getMethod();
				boolean isGet = HttpMethod.GET.matches(method);
				if (isGet || HttpMethod.HEAD.matches(method)) {
					long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
					if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) {
						return;
					}
				}

				if (!mappedHandler.applyPreHandle(processedRequest, response)) {
					return;
				}

				// Actually invoke the handler.
				//3.由匹配的HandlerAdapter调用Handler中的指定的方法
				//例如: SimpleControllerHandlerAdapter最终其实由Handler(HelloController)调用其里面的方法handleRequest()方法
				mv = ha.handle(processedRequest, response, mappedHandler.getHandler());

				if (asyncManager.isConcurrentHandlingStarted()) {
					return;
				}

				applyDefaultViewName(processedRequest, mv);
				mappedHandler.applyPostHandle(processedRequest, response, mv);
			}
			catch (Exception ex) {
				dispatchException = ex;
			}
			catch (Throwable err) {
				// As of 4.3, we're processing Errors thrown from handler methods as well,
				// making them available for @ExceptionHandler methods and other scenarios.
				dispatchException = new ServletException("Handler dispatch failed: " + err, err);
			}

			//4.该方法的底层会由配置的视图解析器解析并渲染视图
			processDispatchResult(processedRequest, response, mappedHandler, mv, dispatchException);
		}
		catch (Exception ex) {
			triggerAfterCompletion(processedRequest, response, mappedHandler, ex);
		}
		catch (Throwable err) {
			triggerAfterCompletion(processedRequest, response, mappedHandler,
					new ServletException("Handler processing failed: " + err, err));
		}
		finally {
			if (asyncManager.isConcurrentHandlingStarted()) {
				// Instead of postHandle and afterCompletion
				if (mappedHandler != null) {
					mappedHandler.applyAfterConcurrentHandlingStarted(processedRequest, response);
				}
				asyncManager.setMultipartRequestParsed(multipartRequestParsed);
			}
			else {
				// Clean up any resources used by a multipart request.
				if (multipartRequestParsed || asyncManager.isMultipartRequestParsed()) {
					cleanupMultipart(processedRequest);
				}
			}
		}
	}


